package net.starelement.digwartnt;

import cn.nukkit.plugin.PluginBase;
import net.starelement.gamelib.ListenerConfig;
import net.starelement.digwartnt.game.GameReady;


/**  StarElement DigwarTNT 主类
 *
 * @author Ruok233
 * @since NukkitX API 1.0.9 | StarElement Project v1-alpaca
 *
 * create: 2019/12/05
 */
public class DigwarTNT extends PluginBase {

    public static DigwarTNT instance;

    private long startTime;

    @Override
    public void onLoad() {
        super.onLoad();
        instance = this;
        startTime = System.currentTimeMillis();
    }

    @Override
    public void onEnable() {
        super.onEnable();

        //注册游戏事件监听器
        this.getServer().getPluginManager().registerEvents(new Listener(), this);

        //注册基础事件监听器
        ListenerConfig listenerConfig = new ListenerConfig();
        listenerConfig.noDiscard = true;
        listenerConfig.diedWithoutDrop = true;
        listenerConfig.lockTime = true;
        listenerConfig.time = 6000;
        listenerConfig.weatherChange = true;
        listenerConfig.noPick = true;
        listenerConfig.joinToSpawn = true;
        this.getServer().getPluginManager().registerEvents(new net.starelement.gamelib.Listener(listenerConfig), this);

        getServer().getLogger().info("§f掘战TNT(§aDigwarTNT§f)已启动...  耗时 §a" + (System.currentTimeMillis() - startTime) + "§fms");
        new GameReady(2);
    }

    public static DigwarTNT getInstance() {
        return instance;
    }
}
